//var keyId=document.cookie.split(";")[0].split("=")[0];
var local="http://47.104.10.151";

var keyId=getCookie('userId');
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
var page=0;

function createXMLHttp() {
    //使用大部分浏览器
    var xmlHttp;
    if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
    }
    if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        if(!xmlHttp){
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    return xmlHttp;
}

function getInvite() {
    var kid=getCookie('userId');
    var url = local+":8080/login/displayCompany_Code";
    xmlHttp = creatxmlHTTPInvite();
    var txt = "";//用于存储拼接字符串；
    //获取数据
    //拼接字符
    txt = "user_Id=" + kid;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    function creatxmlHTTPInvite() {
        if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlHttp=new XMLHttpRequest();
        }else {
            // IE6, IE5 浏览器执行代码
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        return xmlHttp;
    }
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            document.getElementById("invite_code").value=json.msg;
        }
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
function onClickAjax_Reresume(){
    xmlHttp = createXMLHttp();
    var txt = "";//用于存储拼接字符串；
    //拼接字符
    txt = "user_id=" + keyId + "&page=" + page;
    var url=local+":8080/ReqResume/findResume";
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var result = xmlHttp.responseText;
            var json = eval("(" + result + ")");

            totalPages=json.data.totalPages;

            var input1 = document.getElementsByName("talent1");
            input1[0].value = json.data.content[0].name;
            input1[1].value = json.data.content[0].mobile;
            input1[2].value = json.data.content[0].skills;
            input1[3].value = json.data.content[0].service_area;
            input1[4].value = json.data.content[0].money_area;



            var input2 = document.getElementsByName("talent2");
            input2[0].value = json.data.content[1].name;
            input2[1].value = json.data.content[1].mobile;
            input2[2].value = json.data.content[1].skills;
            input2[3].value = json.data.content[1].service_area;
            input2[4].value = json.data.content[1].money_area;


            var input3 = document.getElementsByName("talent3");
            input3[0].value = json.data.content[2].name;
            input3[1].value = json.data.content[2].mobile;
            input3[2].value = json.data.content[2].skills;
            input3[3].value = json.data.content[2].service_area;
            input3[4].value = json.data.content[2].money_area;


            var input4 = document.getElementsByName("talent4");
            input4[0].value = json.data.content[3].name;
            input4[1].value = json.data.content[3].mobile;
            input4[2].value = json.data.content[3].skills;
            input4[3].value = json.data.content[3].service_area;
            input4[4].value = json.data.content[3].money_area;


            var input5 = document.getElementsByName("talent5");
            input5[0].value = json.data.content[4].name;
            input5[1].value = json.data.content[4].mobile;
            input5[2].value = json.data.content[4].skills;
            input5[3].value = json.data.content[4].service_area;
            input5[4].value = json.data.content[4].money_area;


            var input6 = document.getElementsByName("talent6");
            input6[0].value = json.data.content[5].name;
            input6[1].value = json.data.content[5].mobile;
            input6[2].value = json.data.content[5].skills;
            input6[3].value = json.data.content[5].service_area;
            input6[4].value = json.data.content[5].money_area;
        }
    }
}



function sendOneLine() {
    var i=1;
    switch(i){
        case 1:
            sendOneLine1();
        case 2:
            sendOneLine2();
        case 3:
            sendOneLine3();
        case 4:
            sendOneLine4();
        case 5:
            sendOneLine5();
        case 6:
            sendOneLine6();
    }
}
function sendOneLine1() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var doc = document.getElementsByName("talent1");
    if (doc[0].value.length == 0) {
        alert("请填写第一行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}function sendOneLine2() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var kI = 1;
    var doc = document.getElementsByName("talent2");
    if (doc[0].value.length == 0) {
        alert("请填写第二行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}
function sendOneLine3() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var kI = 1;
    var doc = document.getElementsByName("talent3");
    if (doc[0].value.length == 0) {
        alert("请填写第三行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}
function sendOneLine4() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var kI = 1;
    var doc = document.getElementsByName("talent4");
    if (doc[0].value.length == 0) {
        alert("请填写第四行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}
function sendOneLine5() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var kI = 1;
    var doc = document.getElementsByName("talent5");
    if (doc[0].value.length == 0) {
        alert("请填写第五行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}
function sendOneLine6() {
    xmlHttp = createXMLHttp();
    var txt = "";//拼接字符串；
    var kI = 1;
    var doc = document.getElementsByName("talent6");
    if (doc[0].value.length == 0) {
        alert("请填写第六行数据！");
    } else {
        txt = "user_id=" + keyId + "&name=" + doc[0].value + "&mobile=" + doc[1].value + "&skills=" + doc[2].value +
            "&service_area=" + doc[3].value + "&money_area=" + doc[4].value;
        var url = local+":8080/ReqResume/addResume";//服务器URL
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(txt);
    }
}



function nextPage_bid_decision() {
    for(var i=0;i<document.getElementsByName("talent1").length;i++){
        document.getElementsByName("talent1")[i].value="";
    }
    for(var i=0;i<document.getElementsByName("talent2").length;i++){
        document.getElementsByName("talent2")[i].value="";
    }
    for(var i=0;i<document.getElementsByName("talent3").length;i++){
        document.getElementsByName("talent3")[i].value="";
    }
    for(var i=0;i<document.getElementsByName("talent4").length;i++){
        document.getElementsByName("talent4")[i].value="";
    }
    for(var i=0;i<document.getElementsByName("talent5").length;i++){
        document.getElementsByName("talent5")[i].value="";
    }
    for(var i=0;i<document.getElementsByName("talent6").length;i++){
        document.getElementsByName("talent6")[i].value="";
    }
    page++;
    if(totalPages>page){
        onClickAjax_Reresume();
    }
    else alert("已经是最后一页");
}


function beforePage_bid_decision() {
    page--;
    if(page>=0){
        onClickAjax_Reresume();
    }
    else alert("第一页");
}